package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.payment.PaymentBO;
import com.micro.modual.model.dto.payment.PaymentDetailDTO;
import com.micro.modual.model.dto.payment.PaymentListDTO;
import com.micro.modual.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>支付方式表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "支付方式管理",tags = "支付方式管理")
@RestController
@RequestMapping(value = "payment")
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    /**
     * <h2>查找支付方式表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<PaymentListDTO> {@link PaymentListDTO}s  支付方式表 列表返回对象
     */
    @ApiOperation(value = "查询支付方式表列表" ,notes = "查询支付方式表列表")
    @GetMapping(value = "/findPaymentList")
    public RespJsonPageData<PaymentListDTO> findPaymentList(@RequestParam  Map<String,Object> params){
        return paymentService.findList(params,PaymentListDTO.class);
    }

    /**
     * <h2>根据主键编号查看支付方式表详情</h2>
     * @param id  支付方式表 主键编号
     * @return {@link PaymentDetailDTO}  支付方式表 详情
     */
    @ApiOperation(value = "查询支付方式表详情",notes = "根据主键编号，查询支付方式表详情")
    @GetMapping(value = "/findPaymentDetail/{id}")
    public RespJsonData<PaymentDetailDTO> findPaymentDetail(@PathVariable("id") Long id){
        return paymentService.findDetail(id,PaymentDetailDTO.class);
    }

    /**
     * <h2>新增支付方式表详情</h2>
     * @param paymentBO {@link PaymentBO} 支付方式表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增支付方式表",notes = "新增支付方式表")
    @PostMapping(value = "/addPayment")
    public RespJson addPayment(@RequestBody PaymentBO paymentBO){
        return paymentService.addPayment(paymentBO);
    }

    /**
     * <h2>修改支付方式表详情</h2>
     * @param paymentBO  {@link PaymentBO} 支付方式表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改支付方式表",notes = "修改支付方式表")
    @PostMapping(value = "/editPayment")
    public RespJson editPayment(@RequestBody PaymentBO paymentBO){
        return paymentService.editPayment(paymentBO);
    }

    /**
     * <h2>根据主键编号删除支付方式表信息</h2>
     * @param id  支付方式表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除支付方式表",notes = "根据地址ID，删除支付方式表")
    @PostMapping(value = "/deletePayment/{id}")
    public RespJson deletePayment(@PathVariable("id") Long id){
        return paymentService.deletePayment(id);
    }
}

